package isHappy;

public class Solution {
    public boolean isHappy(int n) {
        if(n==0||n==4){
            return false;
        }
        int sum=0;
        while(n>0){
            int a=n%10;
            sum+=(a*a);
            n/=10;
        }
        if(sum==1){
            return true;
        }
        if(sum==n){
            return false;
        }
        return isHappy(sum);
    }
}